<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
<link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet">
<script src="${pageContext.request.contextPath}/js/jquery-1.7.2.js"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
<link href="${pageContext.request.contextPath}/themes/material/easyui.css" rel="stylesheet">
<link href="${pageContext.request.contextPath}/themes/icon.css" rel="stylesheet">
<script src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>
<script src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js"></script>
<title>Insert title here</title>
</head>
<script type="text/javascript">
$(function(){
	//配置搜索框
	$('#searchEmp').searchbox({
		searcher : function(value, name) {
			var uname = value;
			$('#empMsg').datagrid('reload', {
				searchname : uname
			});
		}
	});
	
	
	//默认更新对话框是关闭的
	$('#updateEmp').dialog('close');
	
	//配置修改学生表单
		$("#upEmp").form({
			url:'${pageContext.request.contextPath}/updataEmpPro',
			success:function(data){
				 if(data=="1"){
					$('#updateEmp').dialog('close');
					$("#upEmp").form('clear');
					$.messager.alert('我的消息','更新成功','info',function(){
						$('#empMsg').datagrid('reload');
					});
				 }else{
					 
				 }
			}
		})
	//配置学生数据表格
	$('#empMsg').datagrid({
	    url:'${pageContext.request.contextPath}/findUpEmp',
	    columns:[[    
	        {field:'checked',checkbox : true,width:150}, 
	        {field:'eid',title:'员工编号',width:150,},
	        {field:'ename',title:'员工姓名',width:150},
	        {field:'rid',title:'员工权限',width:150},
	    ]],   
	    pagination : true,
	    
	    toolbar : [ {
			iconCls : 'icon-edit',
			text : '修改(1:超级管理员 2:仓库管理员3:收银员)',
			handler : function() {
				var emps = $("#empMsg").datagrid('getSelections');
				if (emps.length != 1) {
					$.messager.confirm('提示', '请选择一条数据', function(r) {
						if (r) {
							$("#empMsg").datagrid('unselectAll');
						}
					})
				} else {
					$('#updateEmp').dialog('open');
					var emp = emps[0];
					 $('#upEmp').form('load',emp);

				}
			}
		} ],
		striped : true,
				
	});      
})
//配置更新表单提交事件
	function updataForm(){
		$("#upEmp").form('submit');
	}
</script>
<body>

<input id="searchEmp" class="easyui-searchbox"
		data-options="prompt:'输入姓名查询信息',width:150"></input>
		
		<table id="empMsg"></table>
		
		<!-- 修改的对话框 -->
	<div id="updateEmp" class="easyui-dialog" title="更新员工信息"
		style="width: 400px; height: 300px;" data-options="modal:true">
		<form id="upEmp" method="post">
			<div style="margin-bottom: 20px;display: none;">
				<span>员工id</span>
				<input class="easyui-textbox" name="eid" style="width: 100%;">
			</div>
			<div style="margin-bottom: 20px">
				<span>员工姓名</span>
				<input class="easyui-textbox" name="ename" disabled="disabled" style="width: 100%"
					data-options="">
			</div>
			<div style="margin-bottom: 20px">
				<span>员工权限</span> <select id="cc" editable=false  class="easyui-combobox" name="rid"
					style="width: 200px;">
					<option value="1">超级管理员</option>
					<option value="2">仓库管理员</option>
					<option value="3">收银员</option>
					<select>
			</div>
		</form>
		<div style="text-align: center; padding: 5px 0">
			<a href="javascript:void(0)" class="easyui-linkbutton"
				onclick="updataForm()" style="width: 80px">提交</a> 
		</div>
	</div>
</body>
</html>